Skip to main content

System Design Trade-offs

Core Architectural Trade-offs

1. Pull vs. Push

Pull (Client-Initiated)

  • How it works: Client requests data when needed (polling, lazy loading)
  • Pros:
    • Efficient bandwidth usage
    • Clients get exactly what they need
    • Simpler server implementation
  • Cons:
    • Higher latency (data not immediately available)
    • More server requests
    • Potential for stale data

Push (Server-Initiated)

  • How it works: Server proactively sends data (WebSockets, SSE, push notifications)
  • Pros:
    • Real-time updates
    • Lower latency for fresh data
    • Better user experience for live data
  • Cons:
    • Higher bandwidth usage
    • Clients may receive unnecessary data
    • More complex server architecture

When to use:

  • Pull: News feeds, product catalogs, dashboards with refresh buttons, search results
  • Push: Chat applications, live sports scores, stock tickers, collaborative editing tools, gaming

2. Monolith vs. Microservices

Monolith

  • Structure: Single codebase, one deployment unit
  • Pros:
    • Simpler development and testing
    • Easier debugging
    • No network latency between components
    • Simpler deployment
  • Cons:
    • Hard to scale specific components
    • Entire app must be deployed for any change
    • Technology stack locked in
    • Team coordination challenges at scale

Microservices

  • Structure: Independent services per feature/domain
  • Pros:
    • Independent scaling
    • Faster deployment cycles
    • Technology flexibility
    • Team autonomy
  • Cons:
    • Distributed system complexity
    • Network latency
    • Data consistency challenges
    • Operational overhead

When to use:

  • Monolith: Startups, MVPs, small teams, simple domains, low traffic applications
  • Microservices: Large organizations, complex domains, different scaling needs, independent team workflows (Netflix, Amazon, Uber)

3. Synchronous vs. Asynchronous Communication

Synchronous (e.g., HTTP REST, gRPC)

  • How it works: Caller waits for response
  • Pros:
    • Simpler flow and reasoning
    • Immediate error handling
    • Easier debugging
  • Cons:
    • Blocking operations
    • Cascading failures
    • Lower throughput

Asynchronous (e.g., Message Queues, Kafka, Pub/Sub)

  • How it works: Fire and forget, event-driven
  • Pros:
    • Decoupled services
    • Higher throughput
    • Better fault tolerance
    • Load leveling
  • Cons:
    • Complex error handling
    • Eventual consistency
    • Harder debugging

When to use:

  • Synchronous: Payment processing, user authentication, booking confirmations, critical path operations
  • Asynchronous: Email notifications, video processing, log aggregation, analytics events, order processing pipelines

4. SQL vs. NoSQL

SQL (Relational Databases)

  • Examples: PostgreSQL, MySQL, Oracle
  • Pros:
    • Strong consistency (ACID)
    • Complex queries and joins
    • Data integrity guarantees
    • Mature tooling
  • Cons:
    • Harder to scale horizontally
    • Schema changes can be difficult
    • Less flexible for unstructured data

NoSQL

  • Examples: MongoDB (document), Redis (key-value), Cassandra (column), Neo4j (graph)
  • Pros:
    • Horizontal scaling
    • Flexible schema
    • High throughput
    • Better for specific use cases
  • Cons:
    • Eventual consistency (usually)
    • Limited complex querying
    • May lack transactions

When to use:

  • SQL: Banking systems, e-commerce orders, inventory management, HR systems, financial transactions
  • NoSQL: Social media feeds, real-time analytics, caching layers, IoT data, user sessions, product catalogs

Performance Trade-offs

5. Memory vs. Latency

Memory-Heavy (In-Memory)

  • Approach: Store more data in RAM
  • Pros:
    • Extremely low latency (microseconds)
    • Fast data access
  • Cons:
    • Expensive
    • Limited by RAM size
    • Data loss risk without persistence

Memory-Light (Disk/DB)

  • Approach: Minimal in-memory, fetch on demand
  • Pros:
    • Cost-effective
    • Can store massive datasets
  • Cons:
    • Higher latency (milliseconds to seconds)
    • I/O bottlenecks

When to use:

  • Memory-Heavy: Session stores, leaderboards, real-time bidding, autocomplete suggestions, hot data caching (Redis, Memcached)
  • Memory-Light: Archival systems, data warehouses, cold storage, audit logs

6. Throughput vs. Latency

High Throughput

  • Approach: Batch processing, optimize for volume
  • Characteristics: Process many requests, but each may take longer
  • Techniques: Batching, pipelining, connection pooling

Low Latency

  • Approach: Optimize individual request time
  • Characteristics: Fast response, but may limit concurrent processing
  • Techniques: Caching, pre-computation, edge computing

When to use:

  • High Throughput: Video streaming platforms, batch ETL jobs, log processing, analytics pipelines
  • Low Latency: Real-time trading systems, gaming servers, voice/video calls, search autocomplete

7. Latency vs. Accuracy

Low Latency (Approximate Results)

  • Approach: Use approximations, sampling, or probabilistic data structures
  • Pros: Fast responses
  • Cons: Potentially inaccurate

High Accuracy (Exact Results)

  • Approach: Compute precise results
  • Pros: Correct data
  • Cons: Slower response

When to use:

  • Low Latency: Real-time analytics dashboards, recommendation engines, ad targeting, trending topics
  • High Accuracy: Financial calculations, billing systems, inventory counts, audit reports

Consistency & Availability Trade-offs

8. Consistency vs. Availability (CAP Theorem)

CP (Consistency + Partition Tolerance)

  • Behavior: Reject requests when consistency cannot be guaranteed
  • Pros: All nodes always have same data
  • Cons: Lower availability during partitions

AP (Availability + Partition Tolerance)

  • Behavior: Always respond, even with stale data
  • Pros: High availability
  • Cons: Temporary inconsistencies

When to use:

  • CP Systems: Banking transactions, inventory management, seat booking, financial records
  • AP Systems: Social media feeds, comments, likes, DNS, shopping carts, user profiles

9. Strong Consistency vs. Eventual Consistency

Strong Consistency

  • Guarantee: Read always returns most recent write
  • Pros: Predictable behavior, simpler reasoning
  • Cons: Higher latency, lower availability

Eventual Consistency

  • Guarantee: All replicas converge eventually
  • Pros: Better performance, higher availability
  • Cons: Stale reads possible

When to use:

  • Strong Consistency: Bank account balances, stock trading, booking systems, inventory management
  • Eventual Consistency: View counts, likes, follower counts, shopping recommendations, news feeds

10. Cache vs. No Cache

With Cache

  • Pros:
    • Dramatic latency reduction
    • Reduced database load
    • Cost savings
  • Cons:
    • Cache invalidation complexity
    • Stale data risk
    • Additional infrastructure

Without Cache

  • Pros:
    • Always fresh data
    • Simpler architecture
  • Cons:
    • Higher latency
    • Database bottleneck

When to use:

  • With Cache: Product catalogs, user profiles, API responses, static content, session data
  • Without Cache: Real-time stock prices, medical records, legal documents (unless specific caching strategy)

Scaling Trade-offs

11. Vertical vs. Horizontal Scaling

Vertical Scaling (Scale Up)

  • Approach: Bigger, more powerful machine
  • Pros:
    • Simpler architecture
    • No distributed system complexity
  • Cons:
    • Hardware limits
    • Expensive
    • Single point of failure

Horizontal Scaling (Scale Out)

  • Approach: Add more machines
  • Pros:
    • Nearly unlimited scaling
    • Better fault tolerance
    • Cost-effective
  • Cons:
    • Distributed system complexity
    • Data consistency challenges

When to use:

  • Vertical: Databases (initially), legacy applications, tight-coupling requirements
  • Horizontal: Web servers, stateless services, microservices, big data processing

12. Single Database vs. Sharded/Partitioned

Single Database

  • Pros:
    • Simple queries and joins
    • ACID transactions
    • Easier maintenance
  • Cons:
    • Scalability limits
    • Single point of failure

Sharded/Partitioned

  • Pros:
    • Horizontal scaling
    • Handle massive datasets
  • Cons:
    • Complex queries across shards
    • No cross-shard transactions (usually)
    • Rebalancing complexity

When to use:

  • Single Database: Small to medium apps, strong consistency needs, complex relational queries
  • Sharded Database: Social networks, multi-tenant SaaS, global applications, massive user bases (Facebook, Twitter)

Processing Trade-offs

13. Batch vs. Real-Time Processing

Batch Processing

  • Approach: Process data in chunks at intervals
  • Pros:
    • Cost-efficient
    • Simpler error handling
    • Optimized throughput
  • Cons:
    • Delayed insights
    • Not suitable for time-sensitive data

Real-Time Processing (Stream)

  • Approach: Process data immediately as it arrives
  • Pros:
    • Instant insights and actions
    • Better user experience
  • Cons:
    • Complex infrastructure
    • Higher cost

When to use:

  • Batch: Nightly reports, ETL jobs, monthly billing, data warehouse updates, email campaigns
  • Real-Time: Fraud detection, live dashboards, recommendation engines, anomaly detection, traffic monitoring

14. Read vs. Write Optimization

Read-Optimized

  • Techniques: Indexes, read replicas, caching, denormalization
  • Trade-off: Slower writes, more storage

Write-Optimized

  • Techniques: Batch writes, async writes, fewer indexes
  • Trade-off: Slower reads, eventual consistency

When to use:

  • Read-Optimized: News sites, e-commerce product pages, blogs, analytics dashboards
  • Write-Optimized: Logging systems, time-series data, IoT sensors, click tracking, metrics collection

Operational Trade-offs

15. Reliability vs. Speed

High Reliability

  • Techniques: Replication, retries, circuit breakers, failover
  • Pros: Better uptime
  • Cons: Slower responses, more complex

High Speed

  • Techniques: Minimal checks, optimistic locking
  • Pros: Fast responses
  • Cons: Risk of failures

When to use:

  • High Reliability: Payment processing, healthcare systems, aviation systems, critical infrastructure
  • High Speed: Social media interactions, analytics events, view counters

16. Compression vs. CPU Usage

With Compression

  • Pros:
    • Reduced bandwidth
    • Lower storage costs
    • Faster transmission
  • Cons:
    • CPU overhead
    • Increased latency
    • Memory usage

Without Compression

  • Pros:
    • Lower CPU usage
    • Faster processing
  • Cons:
    • Higher bandwidth costs
    • Slower over slow networks

When to use:

  • With Compression: Mobile apps, slow networks, large data transfers, video streaming, API responses
  • Without Compression: Internal datacenter communication, high-speed local networks, small payloads

17. Security vs. Usability

High Security

  • Measures: Strong encryption, 2FA, strict access control, rate limiting
  • Pros: Protected data
  • Cons: Slower operations, friction in UX

High Usability

  • Measures: Minimal auth steps, looser controls
  • Pros: Better user experience
  • Cons: Security vulnerabilities

When to use:

  • High Security: Banking apps, healthcare portals, admin panels, government systems
  • Balanced: Social media (optional 2FA), e-commerce, productivity tools

18. Latency vs. Cost

Low Latency (Higher Cost)

  • Techniques: CDNs, edge computing, premium infrastructure, more caching layers
  • Pros: Better user experience
  • Cons: Expensive

Higher Latency (Lower Cost)

  • Techniques: Single region, fewer caches, shared infrastructure
  • Pros: Cost-effective
  • Cons: Slower for global users

When to use:

  • Low Latency: Gaming, video streaming, financial trading, real-time collaboration
  • Cost-Optimized: Internal tools, batch jobs, archival systems, low-traffic apps

Quick Decision Matrix

System TypeKey Trade-offs
Social Media PlatformAP over CP, Eventual consistency, NoSQL, Push notifications, Horizontal scaling
Banking SystemCP over AP, Strong consistency, SQL, High reliability, ACID transactions
E-commerceRead-optimized, Caching, SQL for orders + NoSQL for catalog, Availability
Chat ApplicationPush over Pull, Low latency, WebSockets, Eventually consistent, Microservices
Analytics PlatformThroughput over latency, Batch + Real-time, NoSQL, Horizontal scaling, Compression
Video StreamingHigh throughput, CDN, Compression, AP, Read-optimized
Real-time TradingLow latency over throughput, Strong consistency, CP, In-memory caching
IoT PlatformWrite-optimized, Time-series DB, Eventual consistency, Stream processing
Search EngineRead-optimized, Heavy caching, Eventual consistency, Horizontal scaling

Key Principles for Interviews

  1. There's no perfect solution – Every choice has trade-offs
  2. Clarify requirements first – Ask about scale, consistency needs, budget
  3. Start simple – Begin with monolith/single DB, explain when to evolve
  4. Justify your choices – Explain why you chose one approach over another
  5. Consider evolution – How does the system scale as requirements change?
  6. Think about real examples – Reference systems like Netflix, Amazon, Twitter

Remember: The goal isn't to memorize solutions, but to understand the trade-offs and make informed decisions based on specific requirements.